home *** CD-ROM | disk | FTP | other *** search
/ Amoszine PD Edition 0 / Amoszine PD Edition 0.adf / SOURCE_CODE / 4PlrAdapter.AMOS / 4PlrAdapter.amosSourceCode
AMOS Source Code  |  1993-02-25  |  4KB  |  113 lines

  1. Rem
  2. Rem                 Joystick Port Extender 
  3. Rem                        Routine   
  4. Rem                    By Digital Ninja    
  5. Rem
  6. '
  7. Rem THIS declaration is important! 
  8. Dim LEE(1)
  9. '
  10. Rem Now you can add another two joysticks to your games by 
  11. Rem using a Parallel 4 Player Adapter  and  this  Routine! 
  12. '
  13. Rem To use the routine, GOSUB EXT in a control routine  or   
  14. Rem main loop, then use the following rules: 
  15. Rem  
  16. Rem LEE(0) = Joystick Three
  17. Rem LEE(1) = Joystick Four 
  18. Rem
  19. Rem The value returned from these are identical  to  those 
  20. Rem you found find in the AMOS command Joy(0) and  Joy(1). 
  21. Rem
  22. Rem Example: 
  23. Rem  
  24. Rem When dealing with joystick 3, use LEE(0) 
  25. Rem When dealing with joystick 4, use LEE(1) 
  26. Rem and look for:    
  27. Rem  
  28. Rem 1  - UP  
  29. Rem 2  - DOWN  
  30. Rem 4  - LEFT  
  31. Rem 8  - RIGHT 
  32. Rem 16 - FIRE  
  33. Rem
  34. Rem because these values add together when crossed:
  35. Rem
  36. Rem 6  = Down and Left (Diagonal)  
  37. Rem 17 = Up and Fire 
  38. Rem 24 = Right and Fire
  39. Rem 5  = Up and Left (Diagonal)  
  40. Rem
  41. Rem (see AMOS manual for an explanation of this method!)   
  42. '
  43. Rem When you wish to use this routine in your code, extract  
  44. Rem the EXT subroutine from this program.  Place it at  the  
  45. Rem end of your code.  Now enter a line at the  very  start  
  46. Rem of your code to settup a small array:
  47. Rem
  48. Rem DIM LEE(1) 
  49. Rem
  50. Rem Now place the command, GOSUB EXT in your main code  and  
  51. Rem everytime your program passes the  line  Gosub Ext, the
  52. Rem joysticks will be read and their positions will be  put  
  53. Rem in LEE(0) and LEE(1) for use.
  54. '
  55. Rem A small program to show it working!
  56. '
  57. Flash Off : Curs Off : Pen 1 : Paper 0 : Cls 0 : Colour 1,$D0
  58. Do 
  59.  '
  60.  Gosub EXT : Rem This grabs the data from the joysticks 
  61.  '
  62.  Locate 5,5
  63.  Print "Joystick Three = ";
  64.  '  
  65.  If LEE(0)=0 : Print "Not moving!   " : End If 
  66.  If LEE(0)=1 : Print "Up            " : End If 
  67.  If LEE(0)=2 : Print "Down          " : End If 
  68.  If LEE(0)=4 : Print "Left          " : End If 
  69.  If LEE(0)=8 : Print "Right         " : End If 
  70.  If LEE(0)=16 : Print "Fire          " : End If 
  71.  If LEE(0)=5 : Print "Up/Left       " : End If 
  72.  If LEE(0)=6 : Print "Down/Left     " : End If 
  73.  If LEE(0)=9 : Print "Up/Right      " : End If 
  74.  If LEE(0)=10 : Print "Down/Right    " : End If 
  75.  If LEE(0)>16 : Print "Fire Direction" : End If 
  76.  '
  77.  Locate 5,7
  78.  Print "Joystick Four = ";
  79.  '
  80.  If LEE(1)=0 : Print "Not moving!   " : End If 
  81.  If LEE(1)=1 : Print "Up            " : End If 
  82.  If LEE(1)=2 : Print "Down          " : End If 
  83.  If LEE(1)=4 : Print "Left          " : End If 
  84.  If LEE(1)=8 : Print "Right         " : End If 
  85.  If LEE(1)=16 : Print "Fire          " : End If 
  86.  If LEE(1)=5 : Print "Up/Left       " : End If 
  87.  If LEE(1)=6 : Print "Down/Left     " : End If 
  88.  If LEE(1)=9 : Print "Up/Right      " : End If 
  89.  If LEE(1)=10 : Print "Down/Right    " : End If 
  90.  If LEE(1)>16 : Print "Fire Direction" : End If 
  91.  '
  92. Loop 
  93. '
  94. '
  95. Rem This routine is Freeware and you may  freely  use  this  
  96. Rem in your own code! Enjoy! 
  97. '
  98. EXT:
  99.  '
  100.  LEE(0)=0
  101.  If(Peek($BFE101) and %1)=0 : LEE(0)=1 : End If 
  102.  If(Peek($BFE101) and %10)=0 : LEE(0)=2 : End If 
  103.  If(Peek($BFE101) and %100)=0 : LEE(0)=LEE(0)+4 : End If 
  104.  If(Peek($BFE101) and %1000)=0 : LEE(0)=LEE(0)+8 : End If 
  105.  If(Peek($BFD000) and %100)=0 : LEE(0)=LEE(0)+16 : End If 
  106.  LEE(1)=0
  107.  If(Peek($BFE101) and %10000)=0 : LEE(1)=1 : End If 
  108.  If(Peek($BFE101) and %100000)=0 : LEE(1)=2 : End If 
  109.  If(Peek($BFE101) and %1000000)=0 : LEE(1)=LEE(1)+4 : End If 
  110.  If(Peek($BFE101) and %10000000)=0 : LEE(1)=LEE(1)+8 : End If 
  111.  If(Peek($BFD000) and %1)=0 : LEE(1)=LEE(1)+16 : End If 
  112.  '
  113. Return